<template>
	<view>
		<view class="page">
			<view class="main">
				<view class="card" style="margin-bottom: 26rpx;">
					<view class="user-wrap">
						<view class="msg">
							<view class="name">
								{{member.name}}
								<image class="vip" src="../../../static/img/vip-icon.png" mode="widthFix"
									v-if="member.sfVip==='1'"></image>
							</view>
							<view class="zw">
								{{member.position}}
							</view>
							<view class="company">
								{{company.name?company.name:''}}
							</view>
							<view class="ads">
								<image class="adsIcon" src="../../../static/img/dizhi.png" mode="widthFix"></image>
								{{company.address?company.address:''}}
							</view>
						</view>
						<view class="avatar-wrap">
							<u-avatar mode="aspectFill" size="74rpx" :src="member.headImg?fileServer+member.headImg:null"></u-avatar>
							<view class="lx">
								已有<text style="font-weight: bold;color: #E83149;">{{member.lxNum||0}}</text>人联系
							</view>
						</view>
					</view>
					<view class="line">

					</view>
					<view class="desc">
						主营：{{member.hyflInfo}}等
					</view>
					<view class="desc">
						负责区域：{{member.fzqy?member.fzqy.join(','):'--'}}
					</view>
				</view>
				<view class="btn-list">
					<view class="btn flexAJC" style="background-color: #43B83E;">
						<image class="icon" mode="widthFix" src="../../../static/img/whatsappIcon.png"></image>
						语音
					</view>
					<view class="btn flexAJC" style="background-color: #FA9932;">
						<image class="icon" mode="widthFix" src="../../../static/img/shipin-white.png"></image>
						视频
					</view>
					<view class="btn flexAJC" style="background-color: #4FBFE7;">
						<image class="icon" mode="widthFix" src="../../../static/img/dizhi-white.png"></image>
						导航
					</view>
					<view class="btn flexAJC" style="background-color: #598FEE;">
						<image class="icon" mode="widthFix" src="../../../static/img/Telephone-white.png"></image>
						电话
					</view>
					<view class="btn flexAJC" style="background-color: #16C40B">
						<image class="icon" mode="widthFix" src="../../../static/img/liaoyilia-green.png"></image>
						聊聊
					</view>
					<view class="btn flexAJC" style="background-color: #EB6F3B">
						<image class="icon" mode="widthFix" src="../../../static/img/xianghujiaohuan-shangxia.png">
						</image>
						对接
					</view>
					<view class="btn flexAJC" style="background-color: #FB6484">
						<image class="icon" mode="widthFix" src="../../../static/img/yuetan-white.png"></image>
						约谈
					</view>
					<view class="btn flexAJC" style="background-color: #A177EE">
						+备忘录
					</view>
					<view class="btn flexAJC" style="background-color: #FABD32">
						<image class="icon" mode="widthFix" src="../../../static/img/zhuanfa-white.png"></image>
						转发
					</view>
				</view>
				
				<view class="card" v-for="(item,index) in list" :key="index">
					<view class="content">
						{{item.content}}
					</view>
					<view class="pic-list" v-if="item.productImg&&item.imgList.length">
						<image class="pic" mode="aspectFill" :src="fileServer+itemIn" v-for="(itemIn,i) in item.imgList" :key="i"></image>
					</view>
					<view class="ads">
						<image class="adsIcon" src="../../../static/img/dizhi.png" mode="widthFix"></image>
						{{item.address||'--'}}
					</view>
					<view class="content-btm">
						<view class="time">
							{{item.createTime}}
						</view>
						<view class="btn-list">
							<button :id="item.id" open-type="share" class="btn flexAJC" style="background-color: #FABD32">
								<image class="icon" mode="widthFix" src="../../../static/img/zhuanfa-white.png"></image>
								转发
							</button>
							<view class="btn flexAJC" style="background-color: #16C40B">
								<image class="icon" mode="widthFix" src="../../../static/img/liaoyilia-green.png">
								</image>
								聊聊
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				member: {},
				company: {},
				fileServer: this.$fileServer,
				list:[],
				total:0,
			};
		},
		onLoad(options) {
			if (options.type && options.type === 'look') {
				const eventChannel = this.getOpenerEventChannel();
				// 监听acceptDataFromOpenerPage事件，获取上一页面通过eventChannel传送到当前页面的数据
				eventChannel.on('acceptDataFromOpenerPage', (data) => {
					this.member = data.member
					this.company = data.company
				})
			}else {
				this.getUserInfo()
			}
			this.getGxfbList();
		},
		methods: {
			getGxfbList(){
				this.$api.duijie.getGxfbList().then(res => {
					console.log(res)
					if(res.code==200){
						let list = res.rows;
						list.forEach(ele=>{
							if(ele.productImg){
								ele.imgList = ele.productImg.split(',')
							}else{
								ele.imgList = []
							}
						})
						this.list = list;
						this.total = res.total;
					}
				})
			},

			getUserInfo() {
				this.$api.member.getMemberInfo().then(res => {
					if (res.data.member.fzqy) {
						res.data.member.fzqy = res.data.member.fzqy.split(',')
					}
					if (res.data.member.type == '0') {
						res.data.member.shenfen = '经销商'
					} else if (res.data.member.type == '1') {
						res.data.member.shenfen = '厂家'
					} else if (res.data.member.type == '2') {
						res.data.member.shenfen = '产业链'
					}
					this.member = res.data.member
					if (this.member.companyId) {
						this.company = res.data.company
					}
				})
			},
		},
		// #ifdef MP-WEIXIN
		onShareAppMessage(res) {
			console.log(res)
		    if (res.from === 'button') {// 来自页面内分享按钮
		        console.log('999')
		    }
			let yqrId = uni.getStorageSync("memberId")||''; //此处配置微信小程序的AppId
		    return {
		        title: '名片', //分享的名称
		        path: `/pages/card/cardIndex/cardIndex?yqrId=${yqrId}`,
		    }
		},
		// #endif
	}
</script>

<style lang="scss" scoped>
	.page {
		background-color: #F5F5F5;min-height: 100vh;

		.main {
			position: relative;
			padding: 20rpx;
			overflow: hidden;

			.card {
				width: 100%;
				background: #FFFFFF;
				border-radius: 16rpx;
				padding: 24rpx 20rpx 16rpx 16rpx;
				margin-bottom: 26rpx;

				.user-wrap {
					display: flex;
					justify-content: space-between;

					.msg {
						flex: 1;

						.name {
							display: flex;
							align-items: center;
							flex-wrap: wrap;
							font-size: 28rpx;
							line-height: 40rpx;

							.vip {
								width: 34rpx;
								height: auto;
								margin-left: 10rpx;
							}
						}

						.zw {
							font-size: 24rpx;
							color: #AAAAAA;
							line-height: 34rpx;
							margin-bottom: 12rpx;
						}

						.company {
							font-size: 28rpx;
							font-weight: bold;
							margin-bottom: 8rpx;
						}

						.ads {
							font-size: 28rpx;
							color: #777777;
							display: flex;
							align-items: center;
							flex-wrap: wrap;

							.adsIcon {
								height: auto;
								margin-right: 8rpx;
								width: 20rpx;
							}
						}
					}

					.avatar-wrap {
						flex-shrink: 0;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
						height: 100%;
						align-items: flex-end;

						.tx {
							width: 74rpx;
							height: 74rpx;
							border-radius: 50%;
						}

						.lx {
							font-size: 24rpx;
							margin-top: 60rpx;
						}
					}
				}

				.line {
					width: 100%;
					height: 1px;
					background-color: #F0F0F0;
					margin: 16rpx 0 10rpx;
				}

				.desc {
					margin-top: 10rpx;
					font-size: 28rpx;
					color: #AAAAAA;
				}

				.content {
					font-weight: bold;
					font-size: 28rpx;
					margin-bottom: 12rpx;
				}

				.content-btm {
					display: flex;
					justify-content: space-between;

					.time {
						font-size: 24rpx;
						color: #777777;
					}

					.btn-list {
						margin-top: 12rpx;

						.btn {
							&:nth-child(2n+0) {
								margin-right: 0;
							}
						}

					}
				}

				.pic-list {
					overflow: hidden;

					.pic {
						float: left;
						width: 200rpx;
						height: 200rpx;
						border-radius: 16rpx;
						margin-right: 22rpx;
						margin-bottom: 18rpx;

						&:nth-child(3n+0) {
							margin-right: 0;
						}
					}
				}

				.ads {
					font-size: 28rpx;
					color: #777777;
					display: flex;
					align-items: center;
					flex-wrap: wrap;
					margin-bottom: 12rpx;

					.adsIcon {
						height: auto;
						margin-right: 8rpx;
						width: 20rpx;
					}


				}
			}

			.btn-list {
				margin-top: 10rpx;
				display: flex;
				align-items: center;
				flex-wrap: wrap;

				.btn {
					width: 120rpx;
					height: 50rpx;
					font-size: 24rpx;
					color: #FFFFFF;
					border-radius: 25rpx;
					margin-right: 22rpx;
					margin-bottom: 22rpx;
					padding:0;
					&:nth-child(5n+0) {
						margin-right: 0;
					}

					.icon {
						width: 24rpx;
						height: auto;
						margin-right: 4rpx;
					}
				}
			}
		}
	}
</style>